package cn.smile.controller.core;

import cn.smile.bean.dto.core.HomeTopDTO;
import cn.smile.bean.dto.core.MiniProjectHomeDTO;
import cn.smile.bean.dto.core.RecentDataCountDTO;
import cn.smile.business.core.IHomeService;
import cn.smile.commons.enums.basic.MiniProjectCountEnum;
import cn.smile.commons.response.MyResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("api/home")
public class HomeController {

    @Resource
    private IHomeService service;

    @GetMapping("top")
    public MyResult<HomeTopDTO> getHomeTop() {
        return MyResult.OK(service.getHomeTop());
    }

    @GetMapping(value = "getMiniProjectHome")
    public MyResult<MiniProjectHomeDTO> getMiniProjectHome() {
        return MyResult.OK(service.getMiniProjectHome(MiniProjectCountEnum.TODAY));
    }

    @GetMapping(value = "getMiniProjectData")
    public MyResult<MiniProjectHomeDTO> getMiniProjectData() {
        return MyResult.OK(service.getMiniProjectHome(MiniProjectCountEnum.LAST_SEVEN_DAYS));
    }

    @GetMapping(value = "countRecentData")
    public MyResult<RecentDataCountDTO> countRecentData(){
        return MyResult.OK(service.countRecentData());
    }
}
